/**
 * 
 */

(function($) {
	var str = '<h3 class="analyse_h3_header">借阅报告</h3><div class="the_show">'
		    +'<h3 class="the_show_header"></h3>'
		    +'<div  class="lcharts_content" ><div class="cost_pie" ></div><div class="describe_left style2"></div></div>'
			+ '<div class="rcharts_content"><div class="cost_rank"></div><div class="describe_right style2"></div></div></div>';
	;
	$('div.charts_right').css({'background':'white','border':'1px solid #d2d2d2'}).append(str);
	var the_str = ' <h3>图书借阅次数分析</h3>' + '<ul>'
	+ '<li><span>0 ~ 20%</span> <span class="blue_span"></span><span class="blue_span"></span><span class="blue_span"></span><span class="blue_span"></span><span class="blue_span"></span></li>'
	+ '<li><span>20% ~ 40%</span> <span class="blue_span"></span><span class="blue_span"></span><span class="blue_span"></span><span class="blue_span"></span><span class="blue_span"></span></li>'
	+ '<li><span>40% ~ 60%</span> <span class="blue_span"></span><span class="blue_span"></span><span class="blue_span"></span><span class="blue_span"></span><span class="blue_span"></span></li>'
	+ '<li><span>60% ~ 80%</span> <span class="blue_span"></span><span class="blue_span"></span><span class="blue_span"></span><span class="blue_span"></span><span class="blue_span"></span></li>'
	+ '<li><span>80% ~ 100%</span> <span class="blue_span"></span><span class="blue_span"></span><span class="blue_span"></span><span class="blue_span"></span><span class="blue_span"></span></li></ul>';
	
			$.getJSON(
					'/WDDXSERVER/report/getReportByBorrowing?callback=?',
					{
						userid : user_id,ticket:ticket
					},
					function(data) {
						$('div.the_show h3:eq(0)').html(
								'本学期共借阅' + data.total + '本')
						var c1 = echarts.init($('.cost_pie')[0], 'macarons');
						c1.hideLoading();
						var option1 = Config('借阅类型分析', '', '本').option2(
								data.pie_data);
						c1.setOption(option1, true);
						$('div.cost_rank ').append(the_str);
						$('div.cost_rank span').css('display', 'inline-block');
						if(data.pm!='100%'&&data.pm!='0%'){
							  var the_rank = parseInt(parseInt(data.pm) / 4);
							  var the_rank_sy = parseInt(data.pm) % 4;
							  if(the_rank_sy!=0)
								  the_rank=the_rank+1;
							  var the_rank_detial,the_rank_detial_sy;
							  the_rank_detial = parseInt(the_rank / 5);
								 the_rank_detial_sy=the_rank % 5;
								 if(the_rank_detial_sy==0)
								   $('div.cost_rank ul li:eq('+(the_rank_detial-1)+') span.blue_span:eq(4)').
								     removeClass('blue_span').addClass('red_span');
								 else
									$('div.cost_rank ul li:eq('+the_rank_detial+') span.blue_span:eq('+(the_rank_detial_sy-1)+')').
								    removeClass('blue_span').addClass('red_span');
							   }
							else if(data.pm=='0%')
								$('div.cost_rank ul li:eq(0) span.blue_span:eq(0)').
							    removeClass('blue_span').addClass('red_span');
							else if(data.pm=='100%')
								$('div.cost_rank ul li:eq(4) span.blue_span:eq(4)').
							    removeClass('blue_span').addClass('red_span');
						$('div.describe_left').append('<h3>你的借阅类型分析结论</h3><p>'+data.describe[0]+'</p>');
						$('div.describe_right').append('<h3>你的借阅水平高于全校'+data.pm+'的学生</h3><p>'+data.describe[0]+'</p>');
						$(window).resize(function() {
							c1.resize();
							c1.setOption(option1);
						});
					});
})(jQuery);